home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
UTILFILE
/
UNPROPTC.LZH
/
GENPATCH.BAS
< prev
next >
Wrap
BASIC Source File
|
1984-02-04
|
2KB
|
54 lines
10 'GENPATCH - generates patches for PATCHER.BAS
20 'Copyright 1983 - Data Base Decisions, Atlanta, GA
90 'If offset is greater than 32,767, BAIC 2.00 must be used.
100 'DOS 2.00 should be used. If this is not possible, use RAM disk.
120 CLS
130 DEFINT A-Z
140 CLEAR
150 ON ERROR GOTO 510
160 INPUT "Old version of file";OFIL$
170 OPEN "i",#1,OFIL$ 'check it is there
180 CLOSE 1
190 OPEN "r",#1,OFIL$,1 'open as random
200 FIELD 1,1 AS O$
210 INPUT "New version of file";NFIL$
220 OPEN "i",#2,NFIL$ 'check it is there
230 CLOSE 2
240 OPEN "r",#2,NFIL$,1 'open as random
250 FIELD 2,1 AS N$
260 INPUT "File in which to save patches";DIF$
270 TMP$="GENPATCH.TMP"
280 OPEN "o",#3,TMP$ 'write to temp file
290 FOR BYTE!=1 TO LOF(1) 'compare the bytes
300 GET 1,BYTE!
310 GET 2,BYTE!
320 IF O$=N$ THEN PRINT "*";: GOTO 380 'they are equal
330 OLDVAL=ASC(O$) 'convert to ascii
340 NEWVAL=ASC(N$)
350 PRINT #3, BYTE! "," OLDVAL "," NEWVAL
360 NEWSUM!=NEWSUM!+BYTE!+OLDVAL+NEWVAL 'keep checksum
365 PRINT: PRINT BYTE!, OLDVAL, NEWVAL,"Checksum ",NEWSUM!
370 IF NEWSUM! > 32767 THEN NEWSUM!=NEWSUM!-32767: GOTO 370
380 NEXT BYTE!
390 CLOSE
400 OPEN "i",#1,TMP$ 'copy temp file to patch file
410 OPEN "o",#2,DIF$
420 PRINT "Comments to be put in " DIF$;: INPUT ""; COMMENT$
430 PRINT #2,NFIL$ "," NEWSUM! "," CHR$(34) COMMENT$ CHR$(34) 'add record
440 IF EOF(1) THEN 480
450 LINE INPUT# 1, X$
460 PRINT #2, X$
470 GOTO 440 'copy another record across
480 CLOSE
490 KILL TMP$ 'delete temp file
500 END
510 REM *** error handler ***
520 UNABLE$="Unable to "
530 IF ERL=170 OR ERL=190 OR ERL=300 THEN PRINT UNABLE$ "read " OFIL$
540 IF ERL=220 OR ERL=240 OR ERL=310 THEN PRINT UNABLE$ "read " NFIL$
550 IF ERL=280 OR ERL=350 THEN PRINT UNABLE$ "write " TMP$
560 IF ERL=400 OR ERL=450 THEN PRINT UNABLE$ "read " TMP$
570 IF ERL=410 OR ERL=460 THEN PRINT UNABLE$ "write " DIF$
580 IF ERL=490 THEN PRINT UNABLE$ "delete " TMP$
590 RESUME 130